package com.ddz.shortcut.utils

import android.util.Log
import android.view.accessibility.AccessibilityEvent

object WindowStateUtils {
    fun isActiveChange(event: AccessibilityEvent): Boolean {
        when {
            event.contentChangeTypes and AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE != 0 -> {
                //源节点的子树发生改变，比如View的增删
                JKShortcutLog.w("插件核心") { "事件 CONTENT_CHANGE_TYPE_SUBTREE" }
                return true
            }
            event.contentChangeTypes and AccessibilityEvent.CONTENT_CHANGE_TYPE_TEXT != 0 -> {
                //节点的文字修改
                JKShortcutLog.w("插件核心") { "事件 CONTENT_CHANGE_TYPE_TEXT" }
                return true
            }
            event.contentChangeTypes and AccessibilityEvent.CONTENT_CHANGE_TYPE_PANE_TITLE != 0 -> {
                //窗格标题修改
                JKShortcutLog.w("插件核心") { "事件 CONTENT_CHANGE_TYPE_PANE_TITLE" }
                return true
            }
            event.contentChangeTypes and AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED != 0 -> {
                //没有定义更改类型
                JKShortcutLog.w("插件核心") { "事件 CONTENT_CHANGE_TYPE_UNDEFINED" }
                return true
            }
            event.contentChangeTypes and AccessibilityEvent.CONTENT_CHANGE_TYPE_PANE_APPEARED != 0 -> {
                //窗格标题出现或分配
                JKShortcutLog.w("插件核心") { "事件 CONTENT_CHANGE_TYPE_PANE_APPEARED" }
                return true
            }
            else ->{
                return false
            }
//            AccessibilityEvent.CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION -> {
//                //更改内容描述
//                return false
//            }
//            AccessibilityEvent.CONTENT_CHANGE_TYPE_STATE_DESCRIPTION -> {
//                //更改状态描述
//                return false
//            }
//            AccessibilityEvent.CONTENT_CHANGE_TYPE_PANE_DISAPPEARED -> {
//                //窗格标题消失并已从节点删除
//                return false
//            }
        }
        return false
    }
}